package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/3/8
 **/
public class oswdemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos=new FileOutputStream("osw.txt");
        //创建转换流时通常会指定第2个参数来明确字符集,以此来保证跨平台性
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("山巅从容的雪");
        osw.write("海上老去的雾");
        System.out.println("写出完毕");
        osw.close();
        /*
        FileOutputStream fos=new FileOutputStream("osw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos,StandardCharsets.UTF_8);
        osw.write("山巅从容的雪");
        osw.write("海上老去的雾");
        System.out.println("写出完毕");
        osw.close;
         */
    }
}
